package yxy.cherry.battle;

import yxy.cherry.battle.module.affix.AffixFactory;
import yxy.cherry.battle.module.anger.Anger;
import yxy.cherry.battle.module.record.FighterPosition;
import yxy.cherry.battle.module.record.stream.RecordStream_ANG;
import yxy.cherry.data.bean.weapondata;

/** 神兵 */
public class NiuBee extends Fighter {

	weapondata data;

	public NiuBee(Team team, weapondata data, int level) throws Exception {
		setTeam(team);
		this.data = data;
		this.怒气 = new Anger(data.getFullanger(), 0, data.getFullanger());

		this.skills.addAll(AffixFactory.getInstance().createAffix(this, data.getSkillid(), level, 1));
	}

	@Override
	public String getName() {
		return "神兵:" + data.getName();
	}

	@Override
	public int getDataId() {
		return data.getId();
	}

	public void add怒气(int point) {
		怒气.addPoint(point);
	}

	@Override
	public void doAct() {
		if (!怒气.isAnger()) {
			return;
		}
		{
			getAffixContext().reset();
			getAffixContext().get攻击行动().set行动者(this);

			handle怒攻();
			initAnger(0);
			getAffixContext().add怒气变动武将(this);
			handle怒后();
		}

		// 怒气变动
		{
//			System.err.println(" getAffixContext().get怒气变动武将()::" + getAffixContext().get怒气变动武将().size());
			for (Fighter fighter : getAffixContext().get怒气变动武将()) {
				getRecord().stream(new RecordStream_ANG(fighter)).record();
			}
		}
	}

	@Override
	public boolean canAct() {
		return true;
	}

	/////////////////////////////////////////////////////////////////

	@Override
	public void setFighterPosition(boolean isLeft) {
		if (this.fighterPosition != null) {
			return;
		}
		this.fighterPosition = isLeft ? FighterPosition.NBL : FighterPosition.NBR;
	}

}
